package com.tedu.bill.demo7;

/**
 * Author：毕龙
 * Date: 2024/4/16 19:26
 */
public class TestPolymorphism1 {
    public static void main(String[] args) {

        //创建人类对象
        Person zirong = new Person();
        //多态的体现 父类的引用
        Pet p3 = zirong.buy(10000);
        //引用的实例对象是否为 该类型
        //如果是 则返回ture  否则是false
        if(p3 instanceof Dog ){
            Dog dog = (Dog) p3;
            dog.eat();
        }


        if(p3 instanceof Cat ){
            Cat cat = (Cat) p3;
            cat.eat();
        }

    }
}
